<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
        <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="keywords" content="Instaright, articles, domains, instaright topics, {{ domain }} articles" />
		<meta name="title" content="Instaright doman articles - {{ domain }}"  />
		<meta name="fragment" content="!" />
		<meta name="description" content="Discover, save and share trending stories from {{ domain }}" />
                <link rel="stylesheet" type="text/css" href="../css/style.css" />
                <!--script src="http://www.google.com/jsapi?key=AIzaSyDu78p4P0qEe3CTU4GssVBz_crZemld_eg" type="text/javascript" charset="utf-8"></script-->
		<script type="text/javascript" src="/_ah/channel/jsapi"></script>
                <!--script src='../static/javascript/channel.js'></script-->
                <script src='../static/javascript/invite.js'></script>
                <script src='../static/javascript/instaright.js'></script>
                <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
                <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
                <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

		<!-- fancybox -->
		<script type="text/javascript" src="/static/javascript/jquery.fancybox-1.3.4.pack.js"></script>
		<link rel="stylesheet" href="/css/jquery.fancybox-1.3.4.css" type="text/css" media="screen" />
		<title>Instaright domain articles  - {{ domain }}</title>

                <!-- google analytics -->
                <script type="text/javascript">

                        var _gaq = _gaq || [];
                        _gaq.push(['_setAccount', 'UA-9005862-5']);
                        _gaq.push(['_trackPageview']);

                        (function() {
                         var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                         ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                         var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
                         })();
                 </script>
                 <!-- Google Website Optimizer Tracking Script -->
         </head>
         <body>
		<script type="text/javascript" charset="utf-8">
		$(document).ready(function(){
			$("#btn_login").fancybox({
				'scrolling'		: 'no',
				'titleShow'		: false,
				'onClosed'		: function(){
				}
			});
		});
		</script>
                <script type="text/javascript" charset="utf-8">
                         if( !window.XMLHttpRequest ) XMLHttpRequest = function(){
        			try{ return new ActiveXObject("Msxml2.XMLHTTP.6.0") }catch(e){}
        			try{ return new ActiveXObject("Msxml2.XMLHTTP.3.0") }catch(e){}
        			try{ return new ActiveXObject("Msxml2.XMLHTTP") }catch(e){}
        			try{ return new ActiveXObject("Microsoft.XMLHTTP") }catch(e){}
        			throw new Error("Could not find an XMLHttpRequest alternative.")
			};
			var channel_id= '{{ channel_id }}';
			var channel = new goog.appengine.Channel(channel_id);
			var socket = channel.open();
			var maxElementsInStream=6;
			var maxHotLinks = 3;
			socket.onopen = function(){
			        //alert('connected');
			}
			socket.onmessage = function(evt){
			        try{
			                feed_json_update = JSON.parse(evt.data);
			                updateDisplayEntry(feed_json_update, stream);
			        } catch(e){
			         //       alert('eee:'+e);
			        } 
			};

			$(document).ready(function(){
					$("#invite_jid").bind('keypress', function(e){
						if (e.keyCode == 13){
						check_and_send_jid();
						}
						});
					$("#invite_jid").focus(function(){
						$(this).val("");
						});
					$.get('/domain/{{ domain }}/feed?format=json', {}, updateDisplayEntry)
					$("#jid_result").hide();
					$("#invite_jid").focus();
			});

			// Create variables to display subscription options using HTML DIVs

			var stream = document.getElementById('stream');

			// Initialize the API.
			var feed;
			function noUpdates(){
                        	container = document.createElement('div');
                        	containerAvatar = document.createElement('div');


                        	titleElement = document.createElement('a');
				titleElement.innerHTML = 'Meh ... no articles for domain {{ domain }}';

                        	domainElement = document.createElement('a');
                        	domainElement.innerHTML = 'Don\'t worry, there are lots of interesting articles one click away :)';
                        	domainElement.href = '/';

                        	container.appendChild(titleElement);
                        	container.appendChild(document.createElement('br'));
                        	container.appendChild(document.createElement('br'));
                        	container.appendChild(domainElement);
                        	container.appendChild(document.createElement('br'));

                		div = document.getElementById('stream');
                        	div.insertBefore(container, div.firstChild);


			}

			function updateDisplayEntry(response, div) {
        			try{
					// check if it is page load
                        		sElements = $("#stream").children();
					if ((typeof(response) == 'undefined' || response.length == 0) && sElements.length == 0){
						noUpdates();
						return;
					}
                			div = document.getElementById('stream');
                			for (i = response.length - 1; i >= 0; i--) {
                        			e = response[i]['u'];
                        			domain = e['d'];
                        			instaright_domain = e['dd'];
                        			try{
                                			title=e['t'];
                        			}catch(e){
                                			title="Instaright article from domain "+domain;
                        			}
                        			if (title == null || title == 'None' || title == 'null' || title.length == 0){
                                			title="Instaright article from domain "+domain;
                        			} else {
                                			try{
                                			if ((title.charCodeAt(0) > 256 || title.charCodeAt(title.length/2) > 256)   && title.length >= 40){
                                        			title = title.substr(0,37) + ' ...';
                                			}
                                			else if (title.length >= 70){
                                        			title = title.substr(0,67) + ' ...';
                                			}
                                			} catch(e){
                                			}
                        			}
                        			link = e['l'];
                        			dateUpdated = new Date(e['u']);
                        			lc = e['lc'];
                        			id = e['id'];
                        			original_link = e['ol'];
						a = e['a'];
						html_lc = e['html_lc'];
						source = e['source'];
						if (typeof(domain) == 'undefined' || (domain != '{{ domain }}')){
							//alert('sanity check did not pass ('+domain+' != {{ domain }}..continue');
							continue;
						} 

						updated_ago_string = "<a href=\""+link+"\">as seen "+updated_string(dateUpdated)+" on Instaright "+ source+"</a>";
                        			container = document.createElement('div');
                        			containerAvatar = document.createElement('div');


                        			avatarElement = document.createElement('img');
                        			avatarElement.setAttribute('src', a);
                        			avatarElement.setAttribute('class', 'avatar');

                        			containerAvatar.appendChild(avatarElement);
                        			container.setAttribute('class', 'streamcontent');
                        			container.setAttribute('id', id);

                        			titleElement = document.createElement('a');
                        			titleElement.innerHTML = title;
						titleElement.setAttribute('class', 'stream-article');
						titleElement.setAttribute('rel', 'nofollow');
                               			titleElement.href = original_link;
                               			titleElement.title = title;
                        			titleElement.target="_new"
                        			titleParagraph = document.createElement('p');
                        			titleParagraph.appendChild(titleElement);

                        			domainElement = document.createElement('a');
                        			domainElement.innerHTML = domain;
						domainElement.setAttribute('class', 'stream-article');
                        			domainElement.href = instaright_domain;
                        			domainElement.target="_new"

                        			container.appendChild(containerAvatar);
                        			container.appendChild(titleParagraph);
                        			container.appendChild(document.createElement('br'));
                        			container.appendChild(domainElement);
                        			container.appendChild(document.createElement('br'));

                        			contentParagraph = document.createElement('div');
						contentParagraph.setAttribute('class', 'category_div');

						/*if (typeof(lc) !== 'undefined' && lc != null && lc != 'null' && lc.length >  1){
							try{
								cats=lc.split(',');
								span_cats=Array();
								for (c in cats){
									span_cats.push("<span class=\"text_bubble_cats\"><a href=\"/category/"+cats[c]+"\">"+cats[c]+"</a></span>");
								}
							}catch(e){
								alert(e);
								span_cats=Array();
							}
							contentParagraph.innerHTML = span_cats.join(" ");
						}*/ 

						contentParagraph.innerHTML = html_lc;
						contentParagraph_footer = document.createElement('div');
						contentParagraph_footer.setAttribute('class', 'content_footer');
						contentParagraph_footer.innerHTML = updated_ago_string;

                        			domainParagraph = document.createElement('p');
                        			domainParagraph.innerHTML = domainElement;

                        			container.appendChild(contentParagraph);
                        			container.appendChild(contentParagraph_footer);
                       
                        			div.insertBefore(container, div.firstChild);
                        			$("#"+id).hide();
                        			$("#"+id).show('blind');
                        			sElements = $("#stream").children();
                        			if (sElements.length > maxElementsInStream ){
                                			lastElement = sElements.get(-1); 
                                			last_id = lastElement.getAttribute('id');
                                			//alert('id:'+ id);
                                			$("#"+last_id).hide();
                                			div.removeChild(lastElement)
                        			}
                			}

        			}catch(e){
                			alert("while adding new element :"+e.message);
        			}
			}
</script>


<div class="wrapper"> 
	<div id="nav" >
		<div class="center clearfix">
			<h5><a href="/">Instaright - Perfect information for you in realtime.</a></h5>
                <ul class="menu borderless clearfix"> 
			<li><a href="/category" title="Instaright most popular category list"><span>Categories</span></a></li>
			<li><a href="/tools" title="Instaright tools"><span>Tools</span></a></li>
                        {% if user %}
			<li><a href="/user/dashboard"><span>{{ user }}</span></a></li>
			<li><a href="/user/dashboard"><img src="{{ avatar }}" width="20" height="20" /></a></li>
			<li><a href="{{ logout_url }}"><span>Logout</span></a></li>
                        {% else %}
			<li><a id="btn_login" href="/account" title="Login to Instaright"><span>Login</span></a></li>
                        {% endif %}
                        <li>
                        </li>

                </ul>
		</div>
	</div>
        <div id="content" class="container_24"> 
                <div id="left_col" class="grid_18"> 
                        <div class="left_box_top"> 
                                <h2 class="round_title"> 
					<span>Instaright Stream articles from {{ domain }}</span> 
                                </h2> 
                        </div> 
                        <div class="left_box_mid">
                                <style> 
                                        #streammap{
                                                border:8px solid #ffffff;
                                                height:230px;
                                                margin:0px 0px 10px 0px;
                                                width:660px;
                                        }
                                        .scan, .streamcontent {
                                                -moz-border-radius:15px;
                                                border:1px solid #ADA699;
                                                clear:both;
                                                display:block;
                                                margin:10px 0px 10px 0px;
                                                padding:10px;
                                                text-decoration:none;
						overflow: auto;
                                        }
                                </style>
                                <div id="stream"></div>
                        </div>
			<div class="left_bot_mid">
				<div class="left_bot_left"></div>
				<div class="left_bot_center"></div>
			</div>
                </div>
                <div id="right_col" class="grid_6">
                        <div id="right_box_top">
                        </div>
                        <div id="right_box_mid">
				{% include 'right_mid.html' %}
                        </div>
                        <div id="right_box_bot">
                        </div>
                </div>
        <div class="clear"></div> 
        <div class="push"></div> 
</div>
<div class="clearfix"></div> 
</div>

<div class="clearfix"></div> 
<div class="footer-container">
	{% include 'footer.html' %}
</div>
<!-- GETSATISFACTION -->
<script type="text/javascript" charset="utf-8">
        var is_ssl = ("https:" == document.location.protocol);
        var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/";
        document.write(unescape("%3Cscript src='" + asset_host + "javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E"));
        </script>

        <script type="text/javascript" charset="utf-8">
                var feedback_widget_options = {};

feedback_widget_options.display = "overlay";  
feedback_widget_options.company = "instaright";
feedback_widget_options.placement = "left";
feedback_widget_options.color = "#222";
feedback_widget_options.style = "idea";
var feedback_widget = new GSFN.feedback_widget(feedback_widget_options);
</script>
<!-- End GETSATISFACTION -->
<!-- Google Website Optimizer Tracking Script -->
		<noscript>
			<h1>Instaright {{ domain }} Article Stream </h1>
			<h2>Check out Instaright articles about {{ domain }}</h2>
			<h3>Looking for more to read? Take a look at <a href="http://www.instaright.com/category/{{ domain }}/feed?format=json" title="Instaright Articles about {{ domain }}">Instaright articles from {{ domain }}</a></h3>
		</noscript>
<script type="text/javascript">
        if(typeof(_gat)!='object')document.write('<sc'+'ript src="http'+
                        (document.location.protocol=='https:'?'s://ssl':'://www')+
                        '.google-analytics.com/ga.js"></sc'+'ript>')</script>
                <script type="text/javascript">
                        try {
                                var gwoTracker=_gat._getTracker("UA-9005862-6");
                                gwoTracker._trackPageview("/2188815013/test");
                                }catch(err){}
                </script>
<!-- End of Google Website Optimizer Tracking Script -->
<!-- apture bar -->
<script id="aptureScript">
(function (){var a=document.createElement("script");a.defer="true";a.src="http://www.apture.com/js/apture.js?siteToken=7TzNhnW";document.getElementsByTagName("head")[0].appendChild(a);})();
</script>

<!-- end apture bar -->

        </body>
</html>
